TARGET = tactics
YACC = yacc
LEX = lex
CC = gcc
LD = gcc
CFLAGS = -g -O2 -Wall -static -std=c99
LFLAGS = 
YYFILE = y.tab.c y.tab.h y.output lex.yy.c
COMMON = tactics.c internal.c backend.c yy.c
HEADER = $(COMMON:%.c=%.h) y.tab.h common.h ast.h
OBJECT = $(COMMON:%.c=%.o) y.tab.o lex.yy.o

default: build

build: $(TARGET)

tactics: $(OBJECT)
	@echo [LD] $@...
	@$(LD) $(LFLAGS) $(OBJECT) -o $@

y.tab.c y.tab.h: t.y
	@echo [YACC]...
	@$(YACC) -v -d t.y

lex.yy.c: t.l $(HEADER)
	@echo [LEX]...
	@$(LEX) t.l

%.o: %.c $(HEADER)
	@echo [CC] $<...
	@$(CC) -c $(CFLAGS) $< -o $@

clean: .PHONY
	@echo [CLEAN]...
	@rm -rf *.core *.o $(YYFILE) $(TARGET)

.PHONY:
